<?php

namespace app\activity\model;

use app\BaseModel;
use app\shop\model\IndexUser;
use think\facade\Db;

/**
 * @mixin think\Model
 */
class ActivityUserRecord extends BaseModel
{
    protected $name = 'lb_activity_user_record';
    protected $pk = 'id';


    public function getListByFilter($filter, $page_config = ['page' => 1, 'page_count' => 20],$where = [])
    {
        $filter['status'] = 1;
        return $this
            ->where($filter)
            ->where($where)
            ->with("userInfo")
            ->field('user_id, create_time, is_sign_in,id')
            ->page($page_config['page'], $page_config['page_count'])->select()->toArray();
    }

    public function countByFilter($filter,$where = [])
    {
        $filter['status'] = 1;
        $result = Db::name($this->name)
            ->where($where)
            ->where($filter)
            ->count();

        return $result;
    }

    public function userInfo()
    {
        return $this->hasOne(IndexUser::class, 'id', 'user_id');
    }


    /**
     * @param $filter
     * @param array $page_config
     * @param array $where
     * @功能说明:获取列表
     * @author chenniang
     * @DataTime: 2020-06-18 09:58
     */

    public function getList($filter,$where = [])
    {
        $filter['status'] = 1;
        return $this
            ->where($filter)
            ->where($where)
            ->with("userInfo")
            ->field('user_id, create_time, is_sign_in,id')
            ->select()
            ->toArray();
    }

}
